
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Bean的生命周期 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Bean的生命周期 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">根据文档，什么是Spring Bean？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在Spring中，构成应用程序主干并由Spring IoC容器管理的对象称为Bean。Bean是由Spring IoC容器实例化、组装和管理的对象。</div>
          </div>
          <div class="card-source">来源: 什么是 Bean</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">普通Java对象和Spring Bean的生命周期管理有何根本区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">普通Java对象在通过`new`创建后即可使用，当不再被引用时由垃圾回收机制回收。而Spring Bean的生命周期完全由IoC容器控制，容器负责其实例化、管理和销毁，开发者无需自己创建对象。</div>
          </div>
          <div class="card-source">来源: Spring Bean的生命周期</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Spring对所有作用域的Bean都进行完整的生命周期管理吗？请说明`prototype`作用域的特殊性。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">不是。文档中明确指出，Spring Bean的生命周期主要指的是singleton bean。对于prototype作用域的bean，Spring在创建好并交给使用者之后，便不再管理其后续的生命周期。</div>
          </div>
          <div class="card-source">来源: Spring Bean的生命周期</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Spring框架管理的Bean包含哪五个主要的生命周期阶段？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">生命周期包括以下五个阶段：1. 实例化 (Instantiation)；2. 属性赋值 (Populate Properties)；3. 初始化 (Initialization)；4. 使用 (In Use)；5. 销毁 (Destruction)。</div>
          </div>
          <div class="card-source">来源: Spring Bean的生命周期</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Spring中，有哪些注解或接口可以用于定义Bean的初始化和销毁回调方法？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">初始化方法可以通过`@PostConstruct`注解或实现`InitializingBean`接口来定义。销毁方法可以通过`@PreDestroy`注解或实现`DisposableBean`接口来定义。</div>
          </div>
          <div class="card-source">来源: Spring Bean的生命周期</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">根据`doCreateBean`源码片段，创建Bean的核心流程分为哪三个步骤？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">核心流程分为三个步骤：1. 实例化 (调用`createBeanInstance`)；2. 属性赋值/依赖注入 (调用`populateBean`)；3. 初始化 (调用`initializeBean`)。</div>
          </div>
          <div class="card-source">来源: Spring Bean初始化的流程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">分类</div>
          <div class="card-question">文档中提到的“Bean级生命周期的方法”主要指哪些接口？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">分类</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要指`BeanNameAware`、`BeanFactoryAware`、`InitializingBean`和`DisposableBean`这些接口的方法。</div>
          </div>
          <div class="card-source">来源: SpringBean生命周期函数分类 -> Bean级生命周期的方法</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">分类</div>
          <div class="card-question">文档如何定义“容器生命周期方法”，并提到了哪两个核心接口？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">分类</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">这类方法的实现类通常被称为“后处理器”（post-processor）。文档中提到的两个核心接口是`InstantiationAwareBeanPostProcessor`和`BeanPostProcessor`。</div>
          </div>
          <div class="card-source">来源: SpringBean生命周期函数分类 -> 容器生命周期方法</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">工厂后处理器（Factory post-processors）在应用上下文启动过程中的调用时机是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">工厂后处理器是容器级的，它在应用上下文装配完配置文件之后被立即调用。</div>
          </div>
          <div class="card-source">来源: SpringBean生命周期函数分类 -> 工厂后处理器接口方</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
